package com.tianji.aigc.config;

import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * spring AI配置类
 */
@Configuration
public class SpringAiConfig {
    @Autowired
    private SessionProperties sessionProperties;

    @Bean
    public ChatClient chatClient(DashScopeChatModel chatModel){
        return ChatClient.builder(chatModel)//对话模型对象
                .defaultSystem(sessionProperties.getSys())
                .defaultAdvisors(new SimpleLoggerAdvisor())//日志记录器
                .build();
    }
}
